package file1;

import java.io.*;

public class Test8 {
    public static void main(String[] args) {
        try (OutputStream outputStream = new FileOutputStream("test/test.txt")) {
            try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream, "utf-8")) {
                try (PrintWriter writer = new PrintWriter(outputStreamWriter)) {
                    writer.println("我是第一行！");
                    writer.print("我是第二行！\n");
                    writer.printf("我是第%d行!\n", 3);
                    writer.flush();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
